/***
 *                 .-~~~~~~~~~-._       _.-~~~~~~~~~-.
 *             __.'              ~.   .~              `.__
 *           .'//                 \./                   \\`.
 *         .'//                     |                     \\`.
 *       .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
 *     .'//.-"                 `-.  |  .-'                 "-.\\`.
 *   .'//______.============-..   \ | /   ..-============.______\\`.
 * .'______________________________\|/______________________________`.
 * When I wrote this, only God and I understood what I was doing
 *                      Now, God only knows
 * ALL IS WELL!!!
 * @author Zero~guang
 * @create 2021-07-15 22:23
 */
package com.qianfeng.strategy.mq.listeners;

import com.qianfeng.smsplatform.common.constants.RabbitMqConsants;
import com.qianfeng.strategy.event.BlackChangeEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class BlackNumChangeListener {
    private ApplicationContext context;
    @Autowired
    public void setContext(ApplicationContext context) {
        this.context = context;
    }

    /**
     * 接收来自于更新黑名单的交换机的消息
     * @param message
     */
    @StreamListener(RabbitMqConsants.TOPIC_BLACKNUM_UPDATE)
    public void onMessage(String message) {
        System.err.println("收到更新黑名单的消息了");
        context.publishEvent(new BlackChangeEvent());
    }
}